#ifndef DEVINFO_H
#define DEVINFO_H

#include <string>
#include <iostream>
#include <fstream>
#include <string>
#include <string_view>
#include <system_error>
#include <filesystem>

#include "util.h"

// 电池信息
class BatteryStatus {
public:
    BatteryStatus() {
        update();
    }

    void update() {
        status = Util::readFileOrDefault(status_path, "Unknown");
        capacity = Util::readFileOrDefault(capacity_path, "Unknown");
    }

    std::string getStatus() const { return status; }
    std::string getCapacity() const { return capacity; }

    static constexpr std::string_view status_path = "/sys/class/power_supply/axp20x-battery/status";
    static constexpr std::string_view capacity_path = "/sys/class/power_supply/axp20x-battery/capacity";

private:
    // 充电状态
    std::string status;
    // 电量百分比
    std::string capacity;
};

class DevInfo {
public:
    // 获取音量
    static int get_volume();

    //设置音量
    static bool set_volume(int volume);

    /*static int read_battery_status(char *status, int *capacity) {
        std::unique_ptr<BatteryStatus> bat = std::make_unique<BatteryStatus>();
        return Util::stringToIntStoi(bat->getStatus());
    }*/
    static bool set_volume_percent(int volume);
};

#endif // DEVINFO_H
